package UIComponents
{
	import MyComponent.MyButton;
	
	import fl.events.ComponentEvent;
	
	import flash.display.DisplayObject;
	import flash.display.DisplayObjectContainer;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.text.TextField;
	
	public class UIMake extends Sprite
	{
		public var mkList:DisplayObject;
		public var upLIst:DisplayObjectContainer;
		public var kdList:DisplayObject;
		
		public var weaponList:DisplayObject;
		
		public var maxList:DisplayObject;
		public var zcUpList:DisplayObject;
		
		public var closeBtn:MyButton;
		
		public var wuButton:MyButton;
		public var kdan:MyButton;
		public var zhizBtn:MyButton;
		public var upBtn:MyButton;
		
		public function UIMake()
		{
			init();
		}
		
		private function init():void
		{
			this.mkList=this.getChildByName("making");
			this.upLIst=this.getChildByName("upgrade") as DisplayObjectContainer;
			this.kdList=this.getChildByName("layer_wallHandler");
			this.weaponList=this.getChildByName("weaponPanel");
			
			this.maxList=this.upLIst.getChildByName("maxUP");
			this.maxList.visible=false;
			
			this.zcUpList=this.upLIst.getChildByName("zcUP");
			
			this.closeBtn=this.getChildByName("button_close") as MyButton;
			
			this.wuButton=this.getChildByName("_wqBtn") as MyButton;
			this.kdan=this.getChildByName("_lanBtn") as MyButton;
			this.zhizBtn=this.getChildByName("_makeBtn") as MyButton;
			this.upBtn=this.getChildByName("upBtn") as MyButton;
			this.kdan["lockState"]=true;
			this.addListener();
		}
		
		//******************箭头****start********
		public function get mkBtnForArrow():DisplayObject
		{
			return (this.mkList as MakingPanel).mkBtnForArrow;
		}
		
		public function get upBtnForArrow():DisplayObject
		{
			return (this.zcUpList as UpgradePanel).upbtn;
		}
		
		public function get djBtn():DisplayObject
		{
			return (this.weaponList as WeaponPanel).wqDjBtn;
		}
		
		public function get sdldFrame():DisplayObject
		{
			return (this.weaponList as WeaponPanel).getMakingListFrame(0);
		}
		
		public function get obkjBtn():DisplayObject
		{
			return (this.kdList as ExpandWall)._obkj;
		}
		
		public function get jbkjBtn():DisplayObject
		{
			return (this.kdList as ExpandWall)._jbkj;
		}
		
		public function get friendkjBtn():DisplayObject
		{
			return (this.kdList as ExpandWall)._friendkj;
		}
		
		//******************箭头****end********
		
		private function closeHandler(e:ComponentEvent):void
		{
			this.dispatchEvent(new PanelEvent(PanelEvent.CLOSE,true));
		}
		
		private function addListener():void
		{
			this.closeBtn.addEventListener(ComponentEvent.BUTTON_DOWN,closeHandler);
			this.weaponList.addEventListener("notInHome",notInHomefun);
			this.weaponList.addEventListener("addarrowtodj",addarrowtodj);
			this.weaponList.addEventListener("zbsdld",zbsdld);
			this.weaponList.addEventListener("notnewguidesd",notnewguidesd);
		}
		
		private function addarrowtodj(e:Event):void
		{
			this.dispatchEvent(new PanelEvent(PanelEvent.ADDARROWTODJ,true));
		}
		
		private function zbsdld(e:Event):void
		{
			this.dispatchEvent(new PanelEvent(PanelEvent.ZBSDLD,true));
		}
		
		private function notnewguidesd(e:Event):void
		{
			this.dispatchEvent(new PanelEvent(PanelEvent.NOTNEWGUIDESD,true));
		}
		
		private function notInHomefun(e:Event):void
		{
			this.dispatchEvent(new PanelEvent(PanelEvent.NOTINHOME,true));
		}
		
		/**
		 * 合成 制作
		 * @param arr
		 */		
		public function setData(arr:Array):void
		{
			((this.mkList) as MakingPanel).setItemsAry(arr);
		}
		
		/**
		 * 升级
		 * @param arr
		 */		
		public function setupData(arr:Array,obj:Object):void
		{
			this.zcUpList.visible=true;
			this.maxList.visible=false;
			((this.zcUpList) as UpgradePanel).setUpData(arr,obj);
		}
		
		/**
		 * 土地拓展
		 * @param arr
		 */		
		public function setWallData(iwall:IHavenWall):void
		{
			((this.kdList) as ExpandWall).setExpandWall(iwall);
		}
		
		/**
		 * 设置键值最大等级时候的值 
		 * @param bulidName
		 * @param lv
		 */		
		public function setMaxInfo(bulidName:String,lv:int):void
		{
			this.zcUpList.visible=false;
			this.maxList.visible=true;
			(this.maxList as MaxBuildPanel).setMaxInfo(bulidName,lv);
		}
			
		
		public function setWeaponData(obj:Object,selectWeapon:Object,LV:Number,isHome:Boolean):void
		{
			((this.weaponList) as WeaponPanel).bulideLv=LV;
			((this.weaponList) as WeaponPanel).isHome=isHome;
			((this.weaponList) as WeaponPanel).setSelectWeaponObjData(selectWeapon);
			((this.weaponList) as WeaponPanel).setItemsAry(obj);
//			((this.weaponList) as WeaponPanel).addTip();
		}
		
		public function setTitle(value:String):void
		{
			(this.getChildByName("titleTxt") as TextField).text=value;
		}

		/**
		 * 玩家已经装备好的武器装备 
		 */
		public function get newWeaponsArr():Array
		{
			return ((this.weaponList) as WeaponPanel).selectWeapons;
		}

		public function get allWeapons():Array
		{
			return ((this.weaponList) as WeaponPanel).allArr;
		}
		
	}
}